#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main(){
	int n,end_,next_i;
	cin>>n;
	int cnt=n;
	int ans[n];
	for(int i=0;i<n;i++){
		cin>>next_i;
		mp[next_i]=i;
	}
	int previous_index=mp[-1];
	while(cnt){
		ans[previous_index]=cnt;
		previous_index=mp[previous_index];
		cnt--;
	}
	for(int i=0;i<n;i++){
		if(i>0) cout<<" ";
		cout<<ans[i]; 
	}
	return 0;
}
